home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / libg_261.zip / libg_261 / libg++ / etc / lf / option.h < prev    next >
C/C++ Source or Header  |  1994-05-13  |  1KB  |  36 lines

  1. // This may look like C code, but it is really -*- C++ -*-
  2. #ifndef option_h
  3. #define option_h 1
  4.  
  5. /* Process directory listing program options. */
  6.  
  7. /* Enumeration of all directory listing options. */
  8. enum option_type
  9. {
  10.   HIDDEN = 01, /* Print hidden files (those beginning with '.') */
  11.   LINK   = 02  /* Distinguish between directory and file links. */
  12. };
  13.  
  14. class Option_Handler
  15. {
  16. private:
  17.   static unsigned option_word;  /* Compact bitwise-storage for program options. */
  18.   static char    *program_name; /* Name of listing program. */
  19.   static void     usage (void); /* Prints usage then exits. */
  20.   
  21. public:
  22.                   Option_Handler (void);                /* Initialize options. */
  23.   void            operator() (int argc, char *argv[]);  /* Process command-line options. */
  24.   int             operator[] (option_type option);      /* Check if option is enabled. */
  25. };
  26.  
  27. /* Speed things up a bit if we're optimizing. */
  28. #ifdef __OPTIMIZE__
  29. inline int
  30. Option_Handler::operator[] (option_type option) 
  31.   return option_word & option;
  32. }
  33. #endif // __OPTIMIZE__
  34. #endif
  35.